package com.yanqu.road.entity.activity.horserun;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.JsonUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@FieldTypeAnnotation(tableName = "t_u_horse_run_activity_user_base")
public class HorseRunUserBaseData extends DataObject {
    @FieldTypeAnnotation(select = true,update = true,desc = "活动id")
    private int activityId;
    @FieldTypeAnnotation(select = true,update = true,desc = "用户id")
    private long userId;
    @FieldTypeAnnotation(desc = "本体外观 0 1 2 3 没选是0")
    private int horseAppearance;
    @FieldTypeAnnotation(desc = "属性点等级 没有技能加成 没有等级固定属性 只有属性点加点 活动内属性")
    private Map<Integer,Integer> pointAttrLevel;
    @FieldTypeAnnotation(desc = "额外等级 目前只有转盘产出")
    private Map<Integer,Integer> extAttr;
    @FieldTypeAnnotation(desc = "总属性值 包括技能 每次开始游戏作为基础值")
    private Map<Integer,Integer> totalAttrMap;
    @FieldTypeAnnotation(desc = "当前活动内评分")
    private long activityGrade;
    @FieldTypeAnnotation(desc = "小马装备")
    private Map<Integer,Integer> equip;
    @FieldTypeAnnotation(desc = "小马已解锁装备")
    private List<Integer> hasUnlockEquip;
    @FieldTypeAnnotation(desc = "技能")
    private Map<Integer,HorseRunSkillData> skill;
    @FieldTypeAnnotation(desc = "已探险次数")
    private int hasOpenGameTime;
    @FieldTypeAnnotation(desc = "属性点")
    private int attrPoint;
    @FieldTypeAnnotation(desc = "小马等级")
    private int horseLevel;
    @FieldTypeAnnotation(desc = "小马经验")
    private long horseExp;
    @FieldTypeAnnotation(desc = "使用干粮数量")
    private int hadUseItemNum;
    @FieldTypeAnnotation(desc = "到达最远关卡")
    private int historyMaxStage;
    @FieldTypeAnnotation(desc = "大吉次数")
    private int bigLuckyTime;
    @FieldTypeAnnotation(desc = "转盘剩余次数")
    private int turnTableRemain;
    @FieldTypeAnnotation(desc = "洗点次数")
    private int refreshAttrTime;

    @FieldTypeAnnotation(desc = "是否有游玩资格 0无资格 1有资格")
    private int canPlay;
    @FieldTypeAnnotation(desc = "锁定商会id")
    private String lockUnionId;

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }
    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public int getHorseAppearance() {
        return horseAppearance;
    }
    public void setHorseAppearance(int horseAppearance) {
        if (this.horseAppearance != horseAppearance) {
            this.horseAppearance = horseAppearance;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, Integer> getPointAttrLevel() {
        return pointAttrLevel;
    }
    public void setPointAttrLevel(Map<Integer, Integer> pointAttrLevel) {
        if (null == pointAttrLevel){
            return;
        }
        if (this.pointAttrLevel == null || !this.pointAttrLevel.equals(pointAttrLevel)) {
            this.pointAttrLevel = pointAttrLevel;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, Integer> getTotalAttrMap() {
        return totalAttrMap;
    }
    public void setTotalAttrMap(Map<Integer, Integer> totalAttrMap) {
        if (null == totalAttrMap){
            return;
        }
        if (this.totalAttrMap == null || !this.totalAttrMap.equals(totalAttrMap)) {
            this.totalAttrMap = totalAttrMap;
            setOp(DataStatus.Update);
        }
    }

    public long getActivityGrade() {
        return activityGrade;
    }
    public void setActivityGrade(long activityGrade) {
        if (this.activityGrade != activityGrade) {
            this.activityGrade = activityGrade;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, Integer> getEquip() {
        return equip;
    }
    public void setEquip(Map<Integer, Integer> equip) {
        if (null == equip){
            return;
        }
        if (this.equip == null || !this.equip.equals(equip)) {
            this.equip = equip;
            setOp(DataStatus.Update);
        }
    }

    public List<Integer> getHasUnlockEquip() {
        return hasUnlockEquip;
    }
    public void setHasUnlockEquip(List<Integer> hasUnlockEquip) {
        if (null == hasUnlockEquip){
            return;
        }
        if (this.hasUnlockEquip == null || !this.hasUnlockEquip.equals(hasUnlockEquip)) {
            this.hasUnlockEquip = hasUnlockEquip;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, com.yanqu.road.entity.activity.horserun.HorseRunSkillData> getSkill() {
        return skill;
    }
    public void setSkill(Map<Integer, com.yanqu.road.entity.activity.horserun.HorseRunSkillData> skill) {
        if (null == skill){
            return;
        }
        if (this.skill == null || !this.skill.equals(skill)) {
            this.skill = skill;
            setOp(DataStatus.Update);
        }
    }

    public int getHasOpenGameTime() {
        return hasOpenGameTime;
    }
    public void setHasOpenGameTime(int hasOpenGameTime) {
        if (this.hasOpenGameTime != hasOpenGameTime) {
            this.hasOpenGameTime = hasOpenGameTime;
            setOp(DataStatus.Update);
        }
    }

    public int getAttrPoint() {
        return attrPoint;
    }
    public void setAttrPoint(int attrPoint) {
        if (this.attrPoint != attrPoint) {
            this.attrPoint = attrPoint;
            setOp(DataStatus.Update);
        }
    }

    public int getHorseLevel() {
        return horseLevel;
    }
    public void setHorseLevel(int horseLevel) {
        if (this.horseLevel != horseLevel) {
            this.horseLevel = horseLevel;
            setOp(DataStatus.Update);
        }
    }

    public long getHorseExp() {
        return horseExp;
    }
    public void setHorseExp(long horseExp) {
        if (this.horseExp != horseExp) {
            this.horseExp = horseExp;
            setOp(DataStatus.Update);
        }
    }

    public int getHadUseItemNum() {
        return hadUseItemNum;
    }
    public void setHadUseItemNum(int hadUseItemNum) {
        if (this.hadUseItemNum != hadUseItemNum) {
            this.hadUseItemNum = hadUseItemNum;
            setOp(DataStatus.Update);
        }
    }

    public int getHistoryMaxStage() {
        return historyMaxStage;
    }
    public void setHistoryMaxStage(int historyMaxStage) {
        if (this.historyMaxStage != historyMaxStage) {
            this.historyMaxStage = historyMaxStage;
            setOp(DataStatus.Update);
        }
    }

    public int getCanPlay() {
        return canPlay;
    }
    public void setCanPlay(int canPlay) {
        if (this.canPlay != canPlay) {
            this.canPlay = canPlay;
            setOp(DataStatus.Update);
        }
    }

    public String getLockUnionId() {
        return lockUnionId;
    }

    public void setLockUnionId(String lockUnionId) {
        if (this.lockUnionId ==null || !this.lockUnionId.equals(lockUnionId)) {
            this.lockUnionId = lockUnionId;
            setOp(DataStatus.Update);
        }
    }

    public int getBigLuckyTime() {
        return bigLuckyTime;
    }
    public void setBigLuckyTime(int bigLuckyTime) {
        if (this.bigLuckyTime != bigLuckyTime) {
            this.bigLuckyTime = bigLuckyTime;
            setOp(DataStatus.Update);
        }
    }

    public int getTurnTableRemain() {
        return turnTableRemain;
    }
    public void setTurnTableRemain(int turnTableRemain) {
        if (this.turnTableRemain != turnTableRemain) {
            this.turnTableRemain = turnTableRemain;
            setOp(DataStatus.Update);
        }
    }

    public List<Integer> getEquipList(){
        List<Integer> equipList = new ArrayList<>();
        equipList.add(equip.getOrDefault(1,0));
        equipList.add(equip.getOrDefault(2,0));
        equipList.add(equip.getOrDefault(3,0));

        return equipList;
    }

    /**
     * 增加基础属性
     * @param type
     * @param value
     */

    public void addExtAttr(int type, int value){
        extAttr.put(type,extAttr.get(type)+value);
        setUpdateOption();
    }

    public void addAttrLevel(int type,int value){
        pointAttrLevel.put(type, pointAttrLevel.get(type)+value);
        setUpdateOption();
    }

    public List<Integer> getSkillList(){
        List<Integer> skillList = new ArrayList<>();
        for (HorseRunSkillData skillData:skill.values()){
            skillList.add(skillData.getSkillId());
        }
        return skillList;
    }

    public Map<Integer, Integer> getExtAttr() {
        return extAttr;
    }

    public void setExtAttr(Map<Integer, Integer> extAttr) {
        if (null == extAttr){
            return;
        }
        if (this.extAttr == null || !this.extAttr.equals(extAttr)) {
            this.extAttr = extAttr;
            setOp(DataStatus.Update);
        }
    }

    public int getRefreshAttrTime() {
        return refreshAttrTime;
    }
    public void setRefreshAttrTime(int refreshAttrTime) {
        if (this.refreshAttrTime != refreshAttrTime) {
            this.refreshAttrTime = refreshAttrTime;
            setOp(DataStatus.Update);
        }
    }

    public String getAppearanceString(){
        return new String(getHorseAppearance()+";"+equip.getOrDefault(1,0)+","+equip.getOrDefault(2,0)+","+equip.getOrDefault(3,0));
    }
}
